<?php
/**
 * The Template for displaying product archives, including the main shop page which is a post type archive.
 *
 * Override this template by copying it to yourtheme/woocommerce/archive-product.php
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     1.6.4
 */

get_header('shop');

global $catfeaturedproductone, $cathowtocontent, $category_ID, $pageid, $term;
		
$taxonomy = get_query_var('taxonomy');
$queried_term = get_query_var($taxonomy);
$terms = get_terms($taxonomy, 'slug='.$queried_term);
if ($terms) {
  foreach($terms as $term) {
  }
}

$pageslug = $term->slug;
$pageid = $term->term_id;
$pagename = single_term_title( "", false );
$category_ID = get_category_id(''.$pagename.'');

?>

	<?php
		/**
		 * woocommerce_before_main_content hook
		 *
		 * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
		 * @hooked woocommerce_breadcrumb - 20
		 */
		do_action('woocommerce_before_main_content');
	?>

		<h1 class="page-title">
			<?php if ( is_search() ) : ?>
				<?php
					printf( __( 'Search Results: &ldquo;%s&rdquo;', 'woocommerce' ), get_search_query() );
					if ( get_query_var( 'paged' ) )
						printf( __( '&nbsp;&ndash; Page %s', 'woocommerce' ), get_query_var( 'paged' ) );
				?>
			<?php elseif ( is_tax() ) : ?>
				<?php echo single_term_title( "", false ); ?>
			<?php else : ?>
				<?php
					$shop_page = get_post( woocommerce_get_page_id( 'shop' ) );

					echo apply_filters( 'the_title', ( $shop_page_title = get_option( 'woocommerce_shop_page_title' ) ) ? $shop_page_title : $shop_page->post_title );
				?>
			<?php endif; ?>
		</h1>
        
<div style="display:none;">
        <?php

$addcontent = the_field('catadditionalcontenton', 'product_cat_'.$term->term_id.'');
$cathowtocontent = the_field('cathowtocontent', 'product_cat_'.$term->term_id.'');
$catlearninguidecontent = the_field('catlearninguidecontent', 'product_cat_'.$term->term_id.'');
$catfaqcontent = the_field('catfaqcontent', 'product_cat_'.$term->term_id.'');
$catfeaturedproductlayout = the_field('catfeaturedproductlayout', 'product_cat_'.$term->term_id.'');
$catfeaturedproductone = the_field('catfeaturedproductone', 'product_cat_'.$term->term_id.'');
$catfeaturedproducttwo = the_field('catfeaturedproducttwo', 'product_cat_'.$term->term_id.'');
$catfeaturedproductthree = the_field('catfeaturedproductthree', 'product_cat_'.$term->term_id.'');
$catfeaturedproductfour = the_field('catfeaturedproductfour', 'product_cat_'.$term->term_id.'');
$catfeaturedproductfive = the_field('catfeaturedproductfive', 'product_cat_'.$term->term_id.'');

?>
</div>
        
        <?php include '/home/silicons/public_html/wp-content/themes/siliconsolar/social-block.php'; ?>
        
        <?php
			// verify that this is a product category page
   			global $wp_query;
    		// get the query object
    		$cat = $wp_query->get_queried_object();
    		// get the thumbnail id user the term_id
    		$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); 
    		// get the image URL
    		$image = wp_get_attachment_url( $thumbnail_id ); 
		?>
        
        <?php // echo $pageslug ; ?>
        
        <?php // dynamic_sidebar( 'sidebar-9' ); ?>
        
        
        <?php // if The Add Content Field Is Set To "YES" Then Display The Category Additional Content Below
			if ($addcontent = 'Yes') {
				include  '/home/silicons/public_html/wp-content/themes/siliconsolar/prod-cat-page-include-topper.php';
			} ?>
        
        <h2 class="pagesubsectionheader">Questions? Ready To Order? Need Assistance?</h2>
        <?php include '/home/silicons/public_html/wp-content/themes/siliconsolar/page-include-contact-block.php'; ?>
        
        <div id="categorypagetopblock">
        	<img src="<?php echo $image ; ?>" align="left" width="200" height="200" alt="<?php echo single_term_title(); ?>" style="margin:0px;margin-right:20px;background:#ffffff;" />
			<p style="font-size:11px;"><?php do_action( 'woocommerce_taxonomy_archive_description' ); ?></p>
            <div style="width:100%;height:0px;clear:both;"></div>
        </div>
        
        <?php // CODE TO INCLUDE THE POST FOR THE CATEGORY INFORMATION GUIDE AT THE BOTTOM OF CAT PAGE IF TAGGED - tag post with the 
			$infoGuide = new WP_Query();
    		$infoGuide->query('tag=' .$pageslug . '&showposts=1&cat=13');
		?>
        
			<?php while ($infoGuide->have_posts()) : $infoGuide->the_post(); ?>
            	<h2 class="pagesubsectionheader">Category Information Guide</h2>
    			<?php the_content(); ?>
			<?php endwhile; ?>
	<?php
		/**
		 * woocommerce_after_main_content hook
		 *
		 * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
		 */
		do_action('woocommerce_after_main_content');
	?>

	<?php
		/**
		 * woocommerce_sidebar hook
		 *
		 * @hooked woocommerce_get_sidebar - 10
		 */
		do_action('woocommerce_sidebar');
	?>

<?php get_footer('shop'); ?>